package com.wyu.notaryserver.util;

import java.util.Random;

public class CustomUUID {

    public static String getUUID() {
        Random random = new Random();

        StringBuilder uuid = new StringBuilder(36);

        // 生成 xxxxxxxx-xxxx-xxxx
        for (int i = 0; i < 8; i++) {
            uuid.append(Integer.toHexString(random.nextInt(16)));
        }
        uuid.append("-");

        for (int i = 0; i < 4; i++) {
            uuid.append(Integer.toHexString(random.nextInt(16)));
        }
        uuid.append("-");

        for (int i = 0; i < 4; i++) {
            uuid.append(Integer.toHexString(random.nextInt(16)));
        }
        uuid.append("-");

        // y部分：确保 y 在 8 到 11 之间
        uuid.append(Integer.toHexString((random.nextInt(4) + 8)));

        uuid.append("-");

        // 生成最后的 xxxxxxxx 部分
        for (int i = 0; i < 12; i++) {
            uuid.append(Integer.toHexString(random.nextInt(16)));
        }

        return uuid.toString();
    }
}
